import Vue from 'vue'

Vue.filter('tabNameCn',function(router){
	if(router.name=='search'){
		return '票务查询'
	}else if(router.name=='enterpriseDetail'){
		return '服务单位'
	}else if(router.name=='banpenStep1'){
		return '钣喷服务'
	}else if(router.name=='banpenStep2'){
		return '服务内容'
	}else if(router.name=='carInfo'){
		return '车辆信息'
	}else if(router.name=='ucenterHome'){
		return '我的爱特'
	}else if(router.name=='ucenterProfile'){
		return '个人资料'
	}else if(router.name=='boundPhone'){
		return '绑定手机'
	}else if(router.name=='feedbackInput'){
		return '意见反馈'
	}else if(router.name=='ucenterCar'){
		return '我的车辆'
	}else if(router.name=='orderCar'){
		return '订单车辆'
	}else if(router.name=='aboutus'){
		return '关于我们'
	}else if(router.name=='orderList'){
		return '我的订单'
	}else if(router.name=='orderDetail'){
		return '订单详情'
	}else if(router.name=='commentInput'){
		return '服务评价'
	}else if(router.name=='successTips'){
		return '提示信息'
	}else if(router.name=='promoList'){
		return '车主福利'
	}else if(router.name=='promoDetail'){
		return '福利详情'
	}else if(router.name=='invite_activity'){
		return '活动详情'
	}else if(router.name=='activity_addr'){
		return '收货信息'
	}else if(router.name=='enterpriseHome'||router.name=='enterprise'){
		return '服务单位'
	}else if(router.name=='enterpriseOrderDetail'||router.name=='maintenanceOrderDetail'){
		return '订单详情'
	}else if(router.name=='orderConfirm'){
		return '确认维修'
	}else if(router.name=='orderCancel'||router.name=='maintenanceOrderCancel'){
		return '取消订单'
	}else if(router.name=='enterpriseOrder'){
		return '全部订单'
	}else if(router.name=='enterpriseOrderSearch'){
		return '搜索订单'
	}else if(router.name=='enterpriseComments'){
		return '收到的评价'
	}else if(router.name=='enterpriseCommentDetail'||router.name=='maintenanceCommentInput' ){
		return '服务评价'
	}else if(router.name=='carBrandList'||router.name=='carTypeList'){
		return '车型选择'
	}else if(router.name=='carDoctorList'){
		return '专家团队'
	}else if(router.name=='customerServiceList'){
		return '在线咨询'
	}else if(router.name=='carDoctorDetail'){
		return '车大夫信息'
	}else if(router.name=='commentList'){
		return '我的评价'
	}else if(router.name=='maintenance'){
		return '上门保养'
	}else if(router.name=='maintenanceItems'){
		return '保养项目'
	}else if(router.name=='maintenanceDetail'){
		return '检测报告'
	}else if(router.name=='maintenanceOrderNewContact'){
		return '联系信息'
	}else if(router.name=='maintenanceOrderConfirm'){
		return '保养服务'
	}
});

//订单状态过滤
Vue.filter('orderStatusFilter',function(status){
	if(status=='1'){
        return '待处理';
    } else if(status=='2'){
        return '待处理';
	} else if(status=='3'){
		return '待维修'
	} else if(status=='4'){
		return '待评价'
	}else if(status=='5'){
		return '已完成';
    }else if(status=='6'){
		return '已关闭';
    } else {
    	return '无效状态';
	}
});

//保养订单状态过滤
Vue.filter('orderStatusBy',function(status){
	if(status=='0'){
		return '待处理';
	}else if(status=='1'){
        return '待维养';
    } else if(status=='2'){
        return '维养中';
	} else if(status=='3'){
		return '维养完成'
	} else if(status=='40'){
		return '待评价'
	}else if(status=='41'){
		return '已评价'
	}else if(status=='5'){
		return '订单已取消';
    }else if(status=='6'){
		return '订单已关闭';
    } else {
    	return '无效状态';
	}
});

//企业订单状态过滤
Vue.filter('orderStatusEnterprise',function(status){
    if(status=='2'){
        return '待确认';
    } else if(status=='3'){
        return '待维修'
    } else if(status=='4'){
        return '待评价'
    }else if(status=='5'){
        return '已完成';
    }else if(status=='6'){
        return '已关闭';
    } else {
        return '无效状态';
    }
});

//车价范围
Vue.filter('carPriceFilter',function(type){
    if(type=='P01'){
        return '10万以内'
    } else if(type=='P02'){
        return '10万~20万'
    } else if(type=='P03'){
        return '20万~30万'
    } else if(type=='P04'){
        return '30万~60万'
    } else if(type=='P05'){
        return '60万以上'
    }
});

//车价范围
Vue.filter('sexFilter',function(type){
    if(type=='1'){
        return '男'
    } else if(type=='2'){
        return '女'
    } else {
        return '保密'
    }
})

//小数点
Vue.filter('toDou',function(input){
    return input%1===0?input+'.0':input;
})

//评价类型
Vue.filter('commentTypeFilter',function(type){
	if(type=='1'){
		return '钣金喷漆'
	} else if(type=='2'){
		return '在线咨询'
	} else if(type=='3'){
		return '保养订单'
	} else  {
		return '无效类型'
	}
})

//时间转换
Vue.filter('date',function(input){
    var oDate=new Date(input);
    var oMonth=oDate.getMonth()+1;
    var oDay=oDate.getDate();
    var oHours=oDate.getHours();
    var oMinutes=oDate.getMinutes();
    var oSeconds=oDate.getSeconds();
    oMonth<10?oMonth='0'+oMonth:oMonth=''+oMonth;
    oDay<10?oDay='0'+oDay:oDay=''+oDay;
    oHours<10?oHours='0'+oHours:oHours=''+oHours;
    oMinutes<10?oMinutes='0'+oMinutes:oMinutes=''+oMinutes;
    oSeconds<10?oSeconds='0'+oSeconds:oSeconds=''+oSeconds;
    return oDate.getFullYear()+'-'+oMonth+'-'+oDay+' '+oHours+':'+oMinutes+':'+oSeconds;
});

//将手机号码中间4位变成*
Vue.filter('starPhone',function(input){
    return input=input.substr(0, 3) + '****' + input.substr(7);
})
Vue.filter('orderPriceInt',
		(input)=>{
		let priceWithPiece = input.split('.');
		return priceWithPiece[0]
	}
)
Vue.filter('orderPriceFloat',
		(input)=>{
			let priceWithPiece = input.split('.');
			return priceWithPiece[1]
		}
)
//显示相对应的配件，且为配件列表中第一个
Vue.filter('filterByPjlbName',(value,input)=>{
	if(input){
		var pj = value.filter(function(item){
			if(item.pjlb==input){
				return item
			}
		});
		function values(obj){
		var values=[];
		for(var pro in obj){
	      values.push(obj[pro]);
	   }
	    return values;
		}
		var vals = values(pj[0]);
		return vals[1]+' '+vals[3]
	}else{
		return '无需使用配件'
	}
})
Vue.filter('filterByPjlbPrice',(value,input1,input2)=>{
	if(input1){
		var pj = value.filter(function(item){
			if(item.pjlb==input1){
				return item
			}
		});
		function values(obj){
		var values=[];
		for(var pro in obj){
	      values.push(obj[pro]);
	   }
	    return values;
		}
		var vals = values(pj[0]);
		return vals[4]
	}else{
		return input2
	}
})
